package main

import (
	"fmt"
	"time"
)

//循环语句
//go没有while语句
func for_statement(){
	for !false{
		fmt.Println("非false的循环...")
	}

	for false {
		//该循环里面 执行体可以为空
	}

	for true {
		fmt.Println("间隔3秒循环....")
		time.Sleep(time.Second*3)
	}

	for true{
		fmt.Println("循环")
	}

	for true {
		//该循环里面不能什么语句也没有


		;  //满足
	}
}


func for_statement2(){
	//var i int = 0     //ok
	var i = 0    		//ok
	for ; i<10; i++  {
		if (i>5) {
			break
		}

		fmt.Println(i*10)

	}

	for j:=0; j<10; j++  {

		//if j>5 {
		//	continue
		//}

		if j==5 {
			continue
		}
		fmt.Println(j * 11)
	}
}


func for_statement3(){
	//var count,c int   //定义变量不使用也会报错
	var i int = 5
	for i>0{
		fmt.Println("i大于0", i)
		i-- //没有此句  将成死循环
	}

	arr := [...]int{21,31,61,71,81,91}
	for i, v := range arr{
		fmt.Println(i, v)
	}
}


func main() {
	//for_statement()

	//for_statement2()

	for_statement3()
}